*************************************************************
*** Analyze the Monte Carlo experiments (SAR data-generating process) for the WWW JoP project
***
*** Created: 9-19-14
*** Modified: 9-5-19
***
*************************************************************

*** Open the data containing the SAR simulations
use "Experiments\SAR\SAR.dta", clear

*** Merge in the true SAR effects dataset
sort rho
merge rho using "Experiments\SAR\SAR--True Effects.dta"
drop _merge

preserve
	duplicates drop rho, force
	gen id = _n
	local end = _N
	sort rho
	tempfile id
	save `id', replace 
restore

sort rho
merge rho using `id'
drop _merge

tempname sar
postfile `sar' str20 model rho rec_beta rec_rho avg_beta avg_rho /*
*/	rec_teffect rec_teffect_o1 rec_teffect_o2 rec_teffect_o3 rec_deffect rec_deffect_o0 rec_deffect_o1 rec_deffect_o2 rec_deffect_o3 rec_ieffect rec_ieffect_o1 rec_ieffect_o2 rec_ieffect_o3 rec_feffect rec_heffect /*
*/	avg_teffect avg_teffect_o1 avg_teffect_o2 avg_teffect_o3 avg_deffect avg_deffect_o0 avg_deffect_o1 avg_deffect_o2 avg_deffect_o3 avg_ieffect avg_ieffect_o1 avg_ieffect_o2 avg_ieffect_o3 avg_feffect avg_heffect /*
*/	avg_ar2 avg_vif /*
*/	true_teffect true_deffect true_ieffect true_feffect true_heffect true_deffect_o0 true_teffect_o1 true_deffect_o1 true_ieffect_o1 true_teffect_o2 true_deffect_o2 true_ieffect_o2 true_teffect_o3 true_deffect_o3 true_ieffect_o3 /*
*/	using "Experiments\Analyze\SAR\Analyze SAR Monte Carlo Experiments.dta", replace 


*** SAR model
preserve
	
	tempvar sig_b_x_sar sig_rho_sar
	gen `sig_b_x_sar' = cond((b_x_sar - 1.96*se_x_sar < b1) & (b_x_sar + 1.96*se_x_sar > b1), 1, 0)
	gen `sig_rho_sar' = cond((rho_sar - 1.96*se_rho_sar < rho) & (rho_sar + 1.96*se_rho_sar > rho), 1, 0)

	foreach v in teffect deffect ieffect feffect heffect {
		tempvar sig_`v' 
		gen `sig_`v'' = cond((`v' - 1.96*`v'_se < true_`v') & (`v' + 1.96*`v'_se > true_`v'), 1, 0)
	}

	tempvar sig_deffect_o0
	gen `sig_deffect_o0' = cond((deffect_o0 - 1.96*deffect_se_o0 < true_deffect_o0) & (deffect_o0 + 1.96*deffect_se_o0 > true_deffect_o0), 1, 0)
	
	foreach o of numlist 1(1)3 {
		foreach e in t d i {
			tempvar sig_`e'effect_o`o' 
			gen `sig_`e'effect_o`o'' = cond((`e'effect_o`o' - 1.96*`e'effect_se_o`o' < true_`e'effect_o`o') & (`e'effect_o`o' + 1.96*`e'effect_se_o`o' > true_`e'effect_o`o'), 1, 0)
		}
	}

	qui foreach n of numlist 1(1)`end' {
		qui sum rho if id == `n'
		local r = round(r(mean), .001)

		foreach v of varlist true_teffect - true_ieffect_o3 true_feffect true_heffect true_deffect_o0 {
			qui sum `v' if id == `n', meanonly
			local `v' = r(mean)
		}
		
		foreach v in b_x_sar rho_sar feffect heffect deffect_o0 {
			sum `v' if id == `n', meanonly
			local avg_`v' = r(mean)
			
			sum `sig_`v'' if id == `n'
			local rec_`v' = 100 * r(mean)
		}
		
		foreach e in t d i {
			sum `e'effect if id == `n', meanonly
			local avg_`e'effect = r(mean)
			
			sum `sig_`e'effect' if id == `n', meanonly
			local rec_`e'effect = 100 * r(mean)
			
			foreach o of numlist 1(1)3 {
				sum `e'effect_o`o' if id == `n', meanonly
				local avg_`e'effect_o`o' = r(mean)
				
				sum `sig_`e'effect_o`o'' if id == `n', meanonly
				local rec_`e'effect_o`o' = 100 * r(mean)
			}
		}
		
		nois di _newline(2) "******************************************************"
		nois di "Rho = `r'; Beta_x = 1"
		nois di "% of cases where SAR Model recovers the true beta_x (reject H_o: beta_x = 1) = " `rec_b_x_sar'
		nois di "% of cases where SAR Model recovers the true rho (reject H_o: rho = `r') = " `rec_rho_sar'
		nois di _newline(2)
		
		post `sar' ("SAR") (`r') (`rec_b_x_sar') (`rec_rho_sar') (`avg_b_x_sar') (`avg_rho_sar') /*
		*/	(`rec_teffect') (`rec_teffect_o1') (`rec_teffect_o2') (`rec_teffect_o3') (`rec_deffect') (`rec_deffect_o0') (`rec_deffect_o1') (`rec_deffect_o2') (`rec_deffect_o3') (`rec_ieffect') (`rec_ieffect_o1') (`rec_ieffect_o2') (`rec_ieffect_o3') (`rec_feffect') (`rec_heffect') /*
		*/	(`avg_teffect') (`avg_teffect_o1') (`avg_teffect_o2') (`avg_teffect_o3') (`avg_deffect') (`avg_deffect_o0') (`avg_deffect_o1') (`avg_deffect_o2') (`avg_deffect_o3') (`avg_ieffect') (`avg_ieffect_o1') (`avg_ieffect_o2') (`avg_ieffect_o3') (`avg_feffect') (`avg_heffect') /*
		*/	(.) (.) /*
		*/	(`true_teffect') (`true_deffect') (`true_ieffect') (`true_feffect') (`true_heffect') (`true_deffect_o0') (`true_teffect_o1') (`true_deffect_o1') (`true_ieffect_o1') (`true_teffect_o2') (`true_deffect_o2') (`true_ieffect_o2') (`true_teffect_o3') (`true_deffect_o3') (`true_ieffect_o3')		
	}
restore

*** SLX model: y = BX + Theta W X
preserve
	local m = 1
	
***********************************************
*** get rid of these after I re-run SAR DGP MC
	gen deffect_o0_m`m' = b_x_m`m'
	gen deffect_o0_se_m`m' = se_x_m`m'
***********************************************

	tempvar sig_b_x sig_deffect_o0
	gen `sig_b_x' = cond((b_x_m`m' - 1.96*se_x_m`m' < b1) & (b_x_m`m' + 1.96*se_x_m`m' > b1), 1, 0)
	gen `sig_deffect_o0' = cond((deffect_o0_m`m' - 1.96*deffect_o0_se_m`m' < true_deffect_o0) & (deffect_o0_m`m' + 1.96*deffect_o0_se_m`m' > true_deffect_o0), 1, 0)
	
	foreach e in t d i {
		tempvar sig_`e'effect 
		gen `sig_`e'effect' = cond((`e'effect_m`m' - 1.96*`e'effect_se_m`m' < true_`e'effect) & (`e'effect_m`m' + 1.96*`e'effect_se_m`m' > true_`e'effect), 1, 0)

		foreach o in 1 {
			tempvar sig_`e'effect_o`o'
			gen `sig_`e'effect_o`o'' = cond((`e'effect_o`o'_m`m' - 1.96*`e'effect_se_o`o'_m`m' < true_`e'effect_o`o') & (`e'effect_o`o'_m`m' + 1.96*`e'effect_se_o`o'_m`m' > true_`e'effect_o`o'), 1, 0)
		}
	}

	qui foreach n of numlist 1(1)`end' {
		sum rho if id == `n', meanonly
		local r = round(r(mean), .001)

		foreach v of varlist true_teffect - true_ieffect_o3 true_deffect_o0 {
			sum `v' if id == `n', meanonly
			local `v' = r(mean)
		}
		
		foreach v in b_x teffect teffect_o1 deffect deffect_o0 deffect_o1 ieffect ieffect_o1 {
			sum `v'_m`m' if id == `n', meanonly
			local avg_`v' = r(mean)
			
			sum `sig_`v'' if id == `n', meanonly
			local rec_`v' = 100 * r(mean)
		
		}
	
		foreach v in ar2 vif {
			sum `v'_m`m' if id == `n', meanonly
			local avg_`v' = r(mean)
		}

		nois di _newline(2) "******************************************************"
		nois di "Rho = `r'; Beta_x = 1"
		nois di "% of cases where SLX Model (1 W) recovers the average total effect = " `rec_teffect'
		nois di "% of cases where SLX Model (1 W) recovers the average first-order total effect = " `rec_teffect_o1'
		nois di _newline(1) "% of cases where SLX Model (1 W) recovers the total average direct effect = " `rec_deffect'
		nois di "% of cases where SLX Model (1 W) recovers the average zero-order direct effect = " `rec_deffect_o0'
		nois di _newline(1) "% of cases where SLX Model (1 W) recovers the total average indirect effect = " `rec_ieffect'
		nois di "% of cases where SLX Model (1 W) recovers the average first-order indirect effect = " `rec_ieffect_o1'
		nois di _newline(2)
		
		post `sar' ("SLX1") (`r') (.) (.) (`avg_b_x') (.) /*
		*/	(`rec_teffect') (`rec_teffect_o1') (.) (.) (`rec_deffect') (`rec_deffect_o0') (`rec_deffect_o1') (.) (.) (`rec_ieffect') (`rec_ieffect_o1') (.) (.) (`rec_feffect') (`rec_heffect') /*
		*/	(`avg_teffect') (`avg_teffect_o1') (.) (.) (`avg_deffect') (`avg_deffect_o0') (`avg_deffect_o1') (.) (.) (`avg_ieffect') (`avg_ieffect_o1') (.) (.) (`avg_feffect') (`avg_heffect') /*
		*/	(`avg_ar2') (`avg_vif') /*
		*/	(`true_teffect') (`true_deffect') (`true_ieffect') (`true_feffect') (`true_heffect') (`true_deffect_o0') (`true_teffect_o1') (`true_deffect_o1') (`true_ieffect_o1') (`true_teffect_o2') (`true_deffect_o2') (`true_ieffect_o2') (`true_teffect_o3') (`true_deffect_o3') (`true_ieffect_o3')		
	}
restore


*** SLX model: y = BX + Theta_1 W X + Theta_2 W^2 X
preserve
	local m = 2

	tempvar sig_b_x sig_deffect_o0
	gen `sig_b_x' = cond((b_x_m`m' - 1.96*se_x_m`m' < b1) & (b_x_m`m' + 1.96*se_x_m`m' > b1), 1, 0)
	gen `sig_deffect_o0' = cond((deffect_o0_m`m' - 1.96*deffect_se_o0_m`m' < true_deffect_o0) & (deffect_o0_m`m' + 1.96*deffect_se_o0_m`m' > true_deffect_o0), 1, 0)
	
	foreach v in teffect deffect ieffect feffect heffect {
		tempvar sig_`v' 
		gen `sig_`v'' = cond((`v'_m`m' - 1.96*`v'_se_m`m' < true_`v') & (`v'_m`m' + 1.96*`v'_se_m`m' > true_`v'), 1, 0)
	}
	
	foreach e in t d i {
		foreach o of numlist 1(1)2 {
			tempvar sig_`e'effect_o`o'
			gen `sig_`e'effect_o`o'' = cond((`e'effect_o`o'_m`m' - 1.96*`e'effect_se_o`o'_m`m' < true_`e'effect_o`o') & (`e'effect_o`o'_m`m' + 1.96*`e'effect_se_o`o'_m`m' > true_`e'effect_o`o'), 1, 0)
		}
	}

	qui foreach n of numlist 1(1)`end' {
		qui sum rho if id == `n'
		local r = round(r(mean), .001)

		foreach v of varlist true_teffect - true_ieffect_o3 true_feffect true_heffect {
			qui sum `v' if id == `n', meanonly
			local `v' = r(mean)
		}

		foreach v in b_x teffect teffect_o1 teffect_o2 deffect deffect_o0 deffect_o1 deffect_o2 ieffect ieffect_o1 ieffect_o2 feffect heffect {
			sum `v'_m`m' if id == `n', meanonly
			local avg_`v' = r(mean)
			
			sum `sig_`v'' if id == `n', meanonly
			local rec_`v' = 100 * r(mean)
		}		
		
		foreach v in ar2 vif {
			sum `v'_m`m' if id == `n', meanonly
			local avg_`v' = r(mean)
		}

		nois di _newline(2) "******************************************************"
		nois di "Rho = `r'; Beta_x = 1"
		nois di "% of cases where SLX Model (2 W) recovers the average total effect = " `rec_teffect'
		nois di "% of cases where SLX Model (2 W) recovers the average first-order total effect = " `rec_teffect_o1'
		nois di "% of cases where SLX Model (2 W) recovers the average second-order total effect = " `rec_teffect_o2'	
		nois di _newline(1) "% of cases where SLX Model (2 W) recovers the total average direct effect = " `rec_deffect'
		nois di "% of cases where SLX Model (2 W) recovers the average zero-order direct effect = " `rec_deffect_o0'
		nois di "% of cases where SLX Model (2 W) recovers the average second-order direct effect = " `rec_deffect_o2'
		nois di _newline(1) "% of cases where SLX Model (2 W) recovers the total average indirect effect = " `rec_ieffect'
		nois di "% of cases where SLX Model (2 W) recovers the average first-order indirect effect = " `rec_ieffect_o1'
		nois di "% of cases where SLX Model (2 W) recovers the average second-order indirect effect = " `rec_ieffect_o2'
		nois di _newline(2)
		
		post `sar' ("SLX2") (`r') (`rec_b_x') (.) (`avg_b_x') (.) /*
		*/	(`rec_teffect') (`rec_teffect_o1') (`rec_teffect_o2') (.) (`rec_deffect') (`rec_deffect_o0') (`rec_deffect_o1') (`rec_deffect_o2') (.) (`rec_ieffect') (`rec_ieffect_o1') (`rec_ieffect_o2') (.) (`rec_feffect') (`rec_heffect') /*
		*/	(`avg_teffect') (`avg_teffect_o1') (`avg_teffect_o2') (.) (`avg_deffect') (`avg_deffect_o0') (`avg_deffect_o1') (`avg_deffect_o2') (.) (`avg_ieffect') (`avg_ieffect_o1') (`avg_ieffect_o2') (.) (`avg_feffect') (`avg_heffect') /*
		*/	(`avg_ar2') (`avg_vif') /*
		*/	(`true_teffect') (`true_deffect') (`true_ieffect') (`true_feffect') (`true_heffect') (`true_deffect_o0') (`true_teffect_o1') (`true_deffect_o1') (`true_ieffect_o1') (`true_teffect_o2') (`true_deffect_o2') (`true_ieffect_o2') (`true_teffect_o3') (`true_deffect_o3') (`true_ieffect_o3')		
	}
restore


*** SLX model: y = BX + Theta_1 W X + Theta_2 W_2 X
preserve
	local m = 3

	tempvar sig_b_x sig_deffect_o0
	gen `sig_b_x' = cond((b_x_m`m' - 1.96*se_x_m`m' < b1) & (b_x_m`m' + 1.96*se_x_m`m' > b1), 1, 0)
	gen `sig_deffect_o0' = cond((deffect_o0_m`m' - 1.96*deffect_se_o0_m`m' < true_deffect_o0) & (deffect_o0_m`m' + 1.96*deffect_se_o0_m`m' > true_deffect_o0), 1, 0)
	
	foreach v in teffect deffect ieffect feffect heffect {
		tempvar sig_`v' 
		gen `sig_`v'' = cond((`v'_m`m' - 1.96*`v'_se_m`m' < true_`v') & (`v'_m`m' + 1.96*`v'_se_m`m' > true_`v'), 1, 0)
	}
	
	foreach e in t d i {
		foreach o of numlist 1(1)2 {
			tempvar sig_`e'effect_o`o'
			gen `sig_`e'effect_o`o'' = cond((`e'effect_o`o'_m`m' - 1.96*`e'effect_se_o`o'_m`m' < true_`e'effect_o`o') & (`e'effect_o`o'_m`m' + 1.96*`e'effect_se_o`o'_m`m' > true_`e'effect_o`o'), 1, 0)
		}
	}
	
	qui foreach n of numlist 1(1)`end' {
		qui sum rho if id == `n'
		local r = round(r(mean), .001)

		foreach v of varlist true_teffect - true_ieffect_o3 true_feffect true_heffect {
			qui sum `v' if id == `n', meanonly
			local `v' = r(mean)
		}
		
		foreach v in b_x teffect teffect_o1 teffect_o2 deffect deffect_o0 deffect_o1 deffect_o2 ieffect ieffect_o1 ieffect_o2 feffect heffect {
			sum `v'_m`m' if id == `n', meanonly
			local avg_`v' = r(mean)
			
			sum `sig_`v'' if id == `n', meanonly
			local rec_`v' = 100 * r(mean)
		}				

		foreach v in ar2 vif {
			sum `v'_m`m' if id == `n', meanonly
			local avg_`v' = r(mean)
		}

		nois di _newline(2) "******************************************************"
		nois di "Rho = `r'; Beta_x = 1"
		nois di "% of cases where SLX Model (2 W_c) recovers the average total effect = " `rec_teffect'
		nois di "% of cases where SLX Model (2 W_c) recovers the average first-order total effect = " `rec_teffect_o1'
		nois di "% of cases where SLX Model (2 W_c) recovers the average second-order total effect = " `rec_teffect_o2'
		nois di _newline(1) "% of cases where SLX Model (2 W_c) recovers the total average direct effect = " `rec_deffect'
		nois di "% of cases where SLX Model (2 W_c) recovers the average zero-order direct effect = " `rec_deffect_o0'
		nois di "% of cases where SLX Model (2 W_c) recovers the average second-order direct effect = " `rec_deffect_o2'
		nois di _newline(1) "% of cases where SLX Model (2 W_c) recovers the total average indirect effect = " `rec_ieffect'
		nois di "% of cases where SLX Model (2 W_c) recovers the average first-order indirect effect = " `rec_ieffect_o1'
		nois di "% of cases where SLX Model (2 W_c) recovers the average second-order indirect effect = " `rec_ieffect_o2'
		nois di _newline(1) "% of cases where SLX Model (2 W_c) finds evidence of feedback effects = " `rec_feffect'
		nois di _newline(1) "% of cases where SLX Model (2 W_c) finds evidence of higher-order effects = " `rec_heffect'
		nois di _newline(2)
		
		post `sar' ("SLX3") (`r') (`rec_b_x') (.) (`avg_b_x') (.) /*
		*/	(`rec_teffect') (`rec_teffect_o1') (`rec_teffect_o2') (.) (`rec_deffect') (`rec_deffect_o0') (`rec_deffect_o1') (`rec_deffect_o2') (.) (`rec_ieffect') (`rec_ieffect_o1') (`rec_ieffect_o2') (.) (`rec_feffect') (`rec_heffect') /*
		*/	(`avg_teffect') (`avg_teffect_o1') (`avg_teffect_o2') (.) (`avg_deffect') (`avg_deffect_o0') (`avg_deffect_o1') (`avg_deffect_o2') (.) (`avg_ieffect') (`avg_ieffect_o1') (`avg_ieffect_o2') (.) (`avg_feffect') (`avg_heffect') /*
		*/	(`avg_ar2') (`avg_vif') /*
		*/	(`true_teffect') (`true_deffect') (`true_ieffect') (`true_feffect') (`true_heffect') (`true_deffect_o0') (`true_teffect_o1') (`true_deffect_o1') (`true_ieffect_o1') (`true_teffect_o2') (`true_deffect_o2') (`true_ieffect_o2') (`true_teffect_o3') (`true_deffect_o3') (`true_ieffect_o3')		
	}
restore



*** SLX model: y = BX + Theta_1 W X + Theta_2 W^2 X + Theta_3 W^3 X
preserve
	local m = 4

	tempvar sig_b_x sig_deffect_o0
	gen `sig_b_x' = cond((b_x_m`m' - 1.96*se_x_m`m' < b1) & (b_x_m`m' + 1.96*se_x_m`m' > b1), 1, 0)
	gen `sig_deffect_o0' = cond((deffect_o0_m`m' - 1.96*deffect_se_o0_m`m' < true_deffect_o0) & (deffect_o0_m`m' + 1.96*deffect_se_o0_m`m' > true_deffect_o0), 1, 0)
	
	foreach v in teffect deffect ieffect feffect heffect {
		tempvar sig_`v' 
		gen `sig_`v'' = cond((`v'_m`m' - 1.96*`v'_se_m`m' < true_`v') & (`v'_m`m' + 1.96*`v'_se_m`m' > true_`v'), 1, 0)
	}
	
	foreach e in t d i {
		foreach o of numlist 1(1)3 {
			tempvar sig_`e'effect_o`o'
			gen `sig_`e'effect_o`o'' = cond((`e'effect_o`o'_m`m' - 1.96*`e'effect_se_o`o'_m`m' < true_`e'effect_o`o') & (`e'effect_o`o'_m`m' + 1.96*`e'effect_se_o`o'_m`m' > true_`e'effect_o`o'), 1, 0)
		}
	}

	qui foreach n of numlist 1(1)`end' {
		qui sum rho if id == `n'
		local r = round(r(mean), .001)

		foreach v of varlist true_teffect - true_ieffect_o3 true_feffect true_heffect {
			qui sum `v' if id == `n', meanonly
			local `v' = r(mean)
		}

		foreach v in b_x teffect teffect_o1 teffect_o2 teffect_o3 deffect deffect_o1 deffect_o0 deffect_o2 deffect_o3 ieffect ieffect_o1 ieffect_o2 ieffect_o3 feffect heffect {
			sum `v'_m`m' if id == `n', meanonly
			local avg_`v' = r(mean)
			
			sum `sig_`v'' if id == `n', meanonly
			local rec_`v' = 100 * r(mean)
		}						

		foreach v in ar2 vif {
			sum `v'_m`m' if id == `n', meanonly
			local avg_`v' = r(mean)
		}
		
		nois di _newline(2) "******************************************************"
		nois di "Rho = `r'; Beta_x = 1"
		nois di "% of cases where SLX Model (3 W) recovers the average total effect = " `rec_teffect'
		nois di "% of cases where SLX Model (3 W) recovers the average first-order total effect = " `rec_teffect_o1'
		nois di "% of cases where SLX Model (3 W) recovers the average second-order total effect = " `rec_teffect_o2'
		nois di "% of cases where SLX Model (3 W) recovers the average third-order total effect = " `rec_teffect_o3'
		nois di _newline(1) "% of cases where SLX Model (3 W) recovers the total average direct effect = " `rec_deffect'
		nois di "% of cases where SLX Model (3 W) recovers the average zero-order direct effect = " `rec_deffect_o0'
		nois di "% of cases where SLX Model (3 W) recovers the average second-order direct effect = " `rec_deffect_o2'
		nois di "% of cases where SLX Model (3 W) recovers the average third-order direct effect = " `rec_deffect_o3'
		nois di _newline(1) "% of cases where SLX Model (3 W) recovers the total average indirect effect = " `rec_ieffect'
		nois di "% of cases where SLX Model (3 W) recovers the average first-order indirect effect = " `rec_ieffect_o1'
		nois di "% of cases where SLX Model (3 W) recovers the average second-order indirect effect = " `rec_ieffect_o2'
		nois di "% of cases where SLX Model (3 W) recovers the average third-order indirect effect = " `rec_ieffect_o3'
		nois di "% of cases where SLX Model (3 W) recovers the average feedback effects = " `rec_feffect'
		nois di "% of cases where SLX Model (3 W) recovers the average higher-order effects = " `rec_heffect'		
		nois di _newline(2)
		
		post `sar' ("SLX4") (`r') (`rec_b_x') (.) (`avg_b_x') (.) /*
		*/	(`rec_teffect') (`rec_teffect_o1') (`rec_teffect_o2') (`rec_teffect_o3') (`rec_deffect') (`rec_deffect_o0') (`rec_deffect_o1') (`rec_deffect_o2') (`rec_deffect_o3') (`rec_ieffect') (`rec_ieffect_o1') (`rec_ieffect_o2') (`rec_ieffect_o3') (`rec_feffect') (`rec_heffect') /*
		*/	(`avg_teffect') (`avg_teffect_o1') (`avg_teffect_o2') (`avg_teffect_o3') (`avg_deffect') (`avg_deffect_o0') (`avg_deffect_o1') (`avg_deffect_o2') (`avg_deffect_o3') (`avg_ieffect') (`avg_ieffect_o1') (`avg_ieffect_o2') (`avg_ieffect_o3') (`avg_feffect') (`avg_heffect') /*
		*/	(`avg_ar2') (`avg_vif') /*
		*/	(`true_teffect') (`true_deffect') (`true_ieffect') (`true_feffect') (`true_heffect') (`true_deffect_o0') (`true_teffect_o1') (`true_deffect_o1') (`true_ieffect_o1') (`true_teffect_o2') (`true_deffect_o2') (`true_ieffect_o2') (`true_teffect_o3') (`true_deffect_o3') (`true_ieffect_o3')		
	}
restore

postclose `sar'

*************************************************************************
************************* Analyze ***************************************
*************************************************************************
use "Experiments\Analyze\SAR\Analyze SAR Monte Carlo Experiments.dta", clear

***************************** True Effects (SAR) ************************
list rho true_teffect true_teffect_o1 true_teffect_o2 true_teffect_o3 if model == "SAR"
list rho true_deffect true_deffect_o1 true_deffect_o2 true_deffect_o3 if model == "SAR"
list rho true_ieffect true_ieffect_o1 true_ieffect_o2 true_ieffect_o3 if model == "SAR"
list rho true_feffect true_heffect if model == "SAR"

***************************** Recovery Rates *****************************
*** Recovery rates of SLX 1: y = XB + Theta W X
list rho rec_teffect - rec_heffect if model == "SLX1"

*** Recovery rates of SLX 2: y = XB + Theta_1 W X + Theta_2 W^2 X
list rho rec_teffect - rec_heffect avg_vif if model == "SLX2"

*** Recovery rates of SLX 3: y = XB + Theta W X + Theta_2 W_2 X
list rho rec_teffect - rec_heffect if model == "SLX3"

*** Recovery rates of SLX 4: y = XB + Theta_1 W X + Theta_2 W^2 X + Theta_3 W^3 X
list rho rec_teffect - rec_heffect avg_vif if model == "SLX4"

***************************** Average Effects *****************************
*** Average effects of SLX 1: y = XB + Theta W X
list rho avg_teffect - avg_heffect if model == "SLX1"

*** Average effects of SLX 2: y = XB + Theta_1 W X + Theta_2 W^2 X
list rho avg_teffect - avg_heffect if model == "SLX2"

*** Average effects of SLX 3: y = XB + Theta W X + Theta_2 W_2 X
list rho avg_teffect - avg_heffect if model == "SLX3"

*** Average effects of SLX 4: y = XB + Theta_1 W X + Theta_2 W^2 X + Theta_3 W^3 X
list rho avg_teffect - avg_heffect if model == "SLX4"
